<?php
// Define path to application directory
defined('SITE_ROOT')
    || define('SITE_ROOT', realpath(dirname(__FILE__)));
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));

// Define application environment
defined('APPLICATION_ENV')
//    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

defined('CAPTCHA_IMG_REFER_PATH')
    || define('CAPTCHA_IMG_REFER_PATH', '/static/captcha/');

defined('CAPTCHA_PATH')
    || define('CAPTCHA_PATH', realpath(dirname(__FILE__) . CAPTCHA_IMG_REFER_PATH));

//define('WINDOWS_ENV', 'windows');
define('LINUX_ENV', 'linux');
define('VIDEO_PREFIX', '/static/vod/');
define('THUMBNAILS_PREFIX', '/static/thumbnails/');
defined('LINUX_ENV') && define('VIDEO_PATH', SITE_ROOT.'/static/vod/');
defined('LINUX_ENV') && define('THUMBNAILS_PATH', SITE_ROOT.'/static/thumbnails/');
defined('LINUX_ENV') && define('TMP_PATH', SITE_ROOT.'/tmp/');
defined('LINUX_ENV') && define('FFMPEG', '/usr/local/bin/ffmpeg');
defined('WINDOWS_ENV') && define('VIDEO_PATH', SITE_ROOT.'\\static\\vod\\');
defined('WINDOWS_ENV') && define('THUMBNAILS_PATH', SITE_ROOT.'\\static\\thumbnails\\');
defined('WINDOWS_ENV') && define('TMP_PATH', SITE_ROOT.'\\tmp\\');
defined('WINDOWS_ENV') && define('FFMPEG', 'ffmpeg.exe');
    
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(SITE_ROOT. '/../library'),
    realpath(SITE_ROOT. '/../library/Qin'),
    get_include_path(),
)));

date_default_timezone_set('Asia/Shanghai');

require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
  printf("%d: %s, %s, %d<br/>", $errno, $errstr, $errfile, $errline);
}
//set_error_handler("myErrorHandler");

Zend_Session::setOptions(array('strict'=>true));

error_reporting(E_ALL);
/** Zend_Application */
require_once 'Zend/Application.php';
//include_once "config/db.php";
include_once "config/config.php";
/* include 'global.php'; */
/* include 'function.php'; */
/* include 'init.php'; */

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
header("Content-type: text/html; charset=utf-8");
$application->bootstrap()
            ->run();
